<template>
  <div class="container">
    <el-dialog
      title="预览文章"
      :visible="showPreDialog"
      width="800px"
      @close="btnCancel"
    >
      <div class="title">
        <h2>{{ currArticle.title }}</h2>
        <div>
          <span>{{ currArticle.createTime | parseTimeByString }}</span>
          <span>{{ currArticle.username }}</span>
          <span class="el-icon-view"></span>
          <span>{{ currArticle.visits }}</span>
        </div>
      </div>
      <div class="content" v-html="currArticle.articleBody"></div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    showPreDialog: {
      type: Boolean,
      default: false,
    },
    currArticle: {
      type: Object,
      required: true,
    },
  },
  methods: {
    btnCancel() {
      this.$emit("update:showPreDialog", false);
    },
  },
};
</script>

<style scoped lang='scss'>
.title {
  border-bottom: 1px dashed #ccc;
  padding-bottom: 10px;
  h2 {
    padding: 0;
    margin: 0;
  }
  span {
    margin-left: 10px;
    margin-top: 10px;
  }
}
.content {
  background: #f5f5f5;
  padding: 10px;
}
</style>
